head = [1, 0, 1]
function ListNode(val, next) {
    this.val = (val === undefined ? 0 : val);
    this.next = (next === undefined ? null : next);
}
let list = new ListNode(head[0]);
let num = list;
// 修正：从索引1开始添加节点（避免重复添加head[0]）
for (let i = 1; i < head.length; i++) {
    num.next = new ListNode(head[i]);
    num = num.next;
}
var getDecimalValue = function (head) {
    let count = 0
    while (head) {
        count = count * 2 + head.val
        head = head.next
    }
    return count

};


console.log(getDecimalValue(list));
